@extends('public')
@section('content')


<div class="wrap">
    <div class="jn_box">
        <div class="jn_box_L">
            @foreach($detail as $key=>$value)
            <div class="jn_con_box">
                <div class="u_pic"><a href="#"><img src="{{asset('images/jn_1.jpg')}}" width="30" height="30"></a></div>
                <div class="u_name"><a href="#"></a></div>
                <h1>{{$value->title}}</h1>
                <div class="yuedu">{{substr( $value->updated_at,0,10)}}</div>
                <div class="time">{{substr( $value->updated_at,0,10)}}</div>
                <div class="clear"></div>
                <div class="content">
                    {!! $value->content !!}
                </div>
                <div class="about">
                    阅读量：{{$value->clicks}}
                    @if( $user != null )
                        <a href="javascript:void(0);" class="zan"  id="isZan" news-id = "{{$value->id}}}" user-id = "{{$user->id}}">赞 </a>
                    @else
                        <a href="javascript:void(0);" class="zan"  id="isZan" news-id = "{{$value->id}}}" >赞 </a>
                    @endif
                </div>
                <div class="comment_box">
                    <form action="{{url('article/silkbagdetail')}}" method="post">
                        {{csrf_field()}}
                        <div class="tit_pl">评论</div>
                        <textarea class="textarea" name="comment"  value="" cols="" rows=""><?php $user = Auth::user(); ?>@if(! $user)请先登录再发表评论@endif</textarea>
                        <div class="num">500字</div>
                        <div class="btn_pl">
                        <?php $user = Auth::user(); ?>
                        @if($user)
                                <input class="btn_pl" name="" type="submit" value="评论" />
                        @else
                            <a href="{{url('user/login')}}">登录</a>
                            {{--<a href="{{url('user/register')}}">注册</a>--}}
                        @endif
                        </div>
                        {{--<input class="btn_pl" name="" type="submit" value="登录" />--}}
                        <div class="clear"></div>
                    </form>
                </div>

                <div class="comm_list_box">
                    <div class="tit_comm">
                        <div class="c_name">共{{$comment->total()}}条评论</div>
                        <div class="clear"></div>
                    </div>

                    <div class="comm_list">
                        <ul>
                            @foreach($comment as $k=>$v)
                            <li>
                                <div class="co_pic"><a href="#"><img src="{{asset('images/jn_1.jpg')}}" width="30" height="30"></a></div>
                                <div class="co_name"><a href="#">一叶之秋</a></div>
                                <div class="co_time">2016-08-10 12:10:55</div>
                                <div class="clear"></div>
                                <div class="co_txt">{{$v->comment}}</div>
                                <div class="about">
                                    <a href="#" class="zan">赞 65</a>
                                    <a href="#" class="re">回复</a>
                                </div>
                            </li>
                            @endforeach
                        </ul>
                    </div>
                    <div class="page">
                        @if ($comment->hasPages())
                            <div class="pager">
                                {!! $comment->appends($appends)->render() !!}
                            </div>
                        @endif
                    </div>

                </div>

            </div>
            @endforeach
        </div>
        <div class="jn_box_R">
            <div class="tit_down">下载客户端</div>
            <div class="pic_box"><a href="#"><img src="{{asset('images/khd.jpg')}}" width="228" height="138"></a></div>
            {{--<div class="pic_box"><a href="#"><img src="{{asset('images/tougao.jpg')}}" width="230" height="60"></a></div>--}}
            <div class="tit_dy"><a href="#">我的订阅</a></div>
            <div class="tit_tj">推荐文章</div>
            <div class="jntj_list">
                <ul>
                    @foreach($lists as $k=>$v)
                    <li>
                        <a href="{{ url('article/silkbagdetail/'.$v->id) }}">{{$v->title}}</a>
                        <div class="about">
                            <span class="yd">阅读 154</span>
                            <span class="zan">赞 65</span>
                            <span class="pl">评论 6</span>
                        </div>
                    </li>
                    @endforeach
                </ul>
            </div>
        </div>
        <div class="clear"></div>
    </div>

</div>

@stop
@section('js')
    <script type="text/javascript" language="JavaScript">
            $(function() {
                $('#isZan').click(function() {
                    var url = '/article/prize-zan';
                    //var url = "{{ url('/article/prize') }}";
                    var userId = $(this).attr('user-id');
                    var newsId = $(this).attr('news-id');
                    var sflData = {};
                    sflData.newsId = newsId;
                    sflData.userId = userId;
                    sflData._token = '{{csrf_token()}}';
                    if( userId == null ) {
                        alert('请先登录再点赞');
                        window.location.href = '/user/login';
                    }
                    $.ajax({
                        url: url,
                        type: 'post',
                        data: sflData,
                        dataType: 'json',
                        success: function( data ) {
                            if (data.code == 200) {
                                alert("点赞成功");
                                return true;
                            }
                            if (data.code == 40002 ) {
                                alert("你已点赞");
                                return true;
                            }
                            if (data.code == 50001 ) {
                                alert("操作失败，请联系管理员");
                                return true;
                            }
                        }
                    })
                });
            });
    </script>
@endsection